﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using facebook.desktop.Properties;
using facebook.Schema;
using facebook;
using  facebook.Components;


namespace facebook.desktop
{
    [ToolboxItem(true), ToolboxBitmap(typeof(BaseControl))]
    public partial class NotificationsList : BaseControl
    {

        FacebookService fbserv;
        public NotificationsList()
        {
            InitializeComponent();
        }
        [Category("Facebook")]
        [Description("")]
        public FacebookService FacebookService
        {

            get { return fbserv; }
            set { fbserv = value;
            this.OnLoad();
            }
        }
        facebook.Schema.notifications  notifications;
        void GetNotifications()
        {
            try
            {
                if(fbserv!=null)
                {
                   
                    notifications = fbserv.API.notifications.get();
                    if(notifications !=null)
                    {
                    
                    this.lblNotText.Text +=notifications.messages.unread.ToString() + " New Messages" + Environment.NewLine;
                    this.lblNotText.Text += notifications.pokes.unread.ToString() + " New Pokes" + Environment.NewLine;
                   // this.lblNotText.Text += notifications.shares.unread.ToString();
                       
                    }

                   
                   

                }
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }


        }
        private void OnLoad()
        {

            try
            {
                if (!IsDesignTime())
                {
                    this.GetNotifications();
                }
                }

            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }

        }

        
      
    }
}
